package com.woniuxy.enjoylife.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.enjoylife.entity.Activity_comment;
import com.woniuxy.enjoylife.entity.RecentComment;
import com.woniuxy.enjoylife.entity.dto.ActivityAndActivityCommentUserDto;
import com.woniuxy.enjoylife.entity.dto.ActivityCommentAndUserDto;
import com.woniuxy.enjoylife.entity.dto.ActivityCommentUserDto;
import com.woniuxy.enjoylife.entity.dto.ActivityShowDto;
import com.woniuxy.enjoylife.mapper.ActivityCommentMapper;
import com.woniuxy.enjoylife.mapper.ActivityMapper;
import com.woniuxy.enjoylife.service.ActivityCommentService;
import com.woniuxy.enjoylife.utils.PageResult;
import com.woniuxy.enjoylife.utils.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ActivityCommentServiceImpl extends ServiceImpl<ActivityCommentMapper,Activity_comment> implements ActivityCommentService {

    @Resource
    private ActivityCommentMapper activityCommentMapper;

    @Resource
    private ActivityMapper activityMapper;


    @Override
    public PageResult<ActivityShowDto> selectAllComment(int page, int size, int uid) {
        return null;
    }

    @Override
    public List<Activity_comment> selectComment(int aid) {
        Activity_comment activityComments = new Activity_comment();
        activityComments.getAid();
        ArrayList<Activity_comment> list = new ArrayList();
        list.add(activityComments);
        return activityCommentMapper.selectComment(aid);
    }

    @Override
    public int addActivityComment(Activity_comment activityComment) {
        return activityCommentMapper.addActivityComment(activityComment);
    }

    @Override
    public int updateActivityComment(Activity_comment activityComment) {
        return activityCommentMapper.updateActivityComment(activityComment);
    }

    @Override
    public int deleteActivityComment(int id) {
        return activityCommentMapper.deleteActivityComment(id);
    }

    //平台查询所有活动评论及其发表人
    @Override
    public PageResult<List<ActivityAndActivityCommentUserDto>> findAllActivityCommentAndUser(int current, int size) {
        PageHelper.startPage(current, size);
        List<ActivityAndActivityCommentUserDto> list = activityCommentMapper.findAllActivityCommentAndUser();
        PageInfo pageInfo = new PageInfo(list);
        PageResult pageResult = PageUtil.setPageResult2(pageInfo);
        return pageResult;
    }

    //平台模糊查询所有人的评论
    @Override
    public PageResult<List<ActivityAndActivityCommentUserDto>> findLikeAllAndUser(String content, int current, int size) {
        PageHelper.startPage(current, size);
        List<ActivityAndActivityCommentUserDto> list = activityCommentMapper.findLikeAllAndUser(content);
        PageInfo pageInfo = new PageInfo(list);
        PageResult pageResult = PageUtil.setPageResult2(pageInfo);
        return pageResult;
    }

    @Override
    public List<ActivityCommentAndUserDto> findActivityComment(Integer id) {
        List<ActivityCommentAndUserDto> activityComments = activityCommentMapper.findActivityComment(id);

        return activityComments;
    }

    @Override
    public List<ActivityCommentAndUserDto> findActivityCommentAndReply(Integer id) {

        List<ActivityCommentAndUserDto> activityCommentAndReply = activityCommentMapper.findActivityCommentAndReply(id);

        return activityCommentAndReply;
    }


}
